From: Georges Basile Stavracas Neto Date: Thu, 31 Dec 2020 17:19:43 +0000 (-0300) Subject: workspacesView: Scale inactive workspaces X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~616^2^2~481 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=4cf5b4a6d8eeb33aab019a25a25bca634b4d71b7;p=gnome-shell.git workspacesView: Scale inactive workspaces As per the latest mockups, then horizontally snapping, the active workspace should be highlighted. Because WorkspacesView clips to allocation, we cannot simply scale up the active one. Instead, scale down the inactive ones. Part-of: --- diff --git a/js/ui/workspace.js b/js/ui/workspace.js index f9e7fad4b..8a9faf4ea 100644 --- a/js/ui/workspace.js +++ b/js/ui/workspace.js @@ -1,7 +1,7 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- /* exported Workspace */ -const { Clutter, GLib, GObject, Meta, St } = imports.gi; +const { Clutter, GLib, GObject, Graphene, Meta, St } = imports.gi; const Background = imports.ui.background; const DND = imports.ui.dnd; @@ -936,6 +936,7 @@ class Workspace extends St.Widget { _init(metaWorkspace, monitorIndex) { super._init({ style_class: 'window-picker', + pivot_point: new Graphene.Point({ x: 0.5, y: 0.5 }), layout_manager: new WorkspaceLayout(metaWorkspace, monitorIndex), reactive: true, }); diff --git a/js/ui/workspacesView.js b/js/ui/workspacesView.js index ac0729dd0..ab8c78c5f 100644 --- a/js/ui/workspacesView.js +++ b/js/ui/workspacesView.js @@ -17,6 +17,8 @@ const MUTTER_SCHEMA = 'org.gnome.mutter'; const WORKSPACE_MIN_SPACING = 24; const WORKSPACE_MAX_SPACING = 80; +const WORKSPACE_INACTIVE_SCALE = 0.94; + var WorkspacesViewBase = GObject.registerClass({ GTypeFlags: GObject.TypeFlags.ABSTRACT, }, class WorkspacesViewBase extends St.Widget { @@ -83,6 +85,7 @@ class WorkspacesView extends WorkspacesViewBase { this._fitModeAdjustment = fitModeAdjustment; this._fitModeNotifyId = this._fitModeAdjustment.connect('notify::value', () => { this._updateVisibility(); + this._updateWorkspacesState(); this.queue_relayout(); }); @@ -212,6 +215,20 @@ class WorkspacesView extends WorkspacesViewBase { return Math.clamp(spacing, WORKSPACE_MIN_SPACING, WORKSPACE_MAX_SPACING); } + _updateWorkspacesState() { + const adj = this._scrollAdjustment; + + // Fade and scale inactive workspaces + this._workspaces.forEach((w, index) => { + const distanceToCurrentWorkspace = Math.abs(adj.value - index); + + const progress = 1 - Math.clamp(distanceToCurrentWorkspace, 0, 1); + + const scale = Util.lerp(WORKSPACE_INACTIVE_SCALE, 1, progress); + w.set_scale(scale, scale); + }); + } + vfunc_allocate(box) { this.set_allocation(box); @@ -349,6 +366,8 @@ class WorkspacesView extends WorkspacesViewBase { this._workspaces[j].destroy(); this._workspaces.splice(j, 1); } + + this._updateWorkspacesState(); } _activeWorkspaceChanged(_wm, _from, _to, _direction) { @@ -411,6 +430,7 @@ class WorkspacesView extends WorkspacesViewBase { metaWorkspace.activate(global.get_current_time()); } + this._updateWorkspacesState(); this.queue_relayout(); } });